/**
 * 
 */
package pit.com.ordermobilesystem.http;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;


/**
 * @author Administrator
 * 
 */
public class StringUtils {
	private static final boolean DEBUG =false;
	private static final Logger LOG = Logger.getLogger(JSONUtils.class
			.getCanonicalName());

	/**
	 * Takes a parser, a json string, and returns a IModel type.
	 */
	public static HttpModel consume(
			Parser<? extends HttpModel> parser, String content)
			throws HttpApiException, IOException {

		if (DEBUG) {
			LOG.log(Level.FINE, "http response: " + content);
		}

		try {
			return parser.parse(content);
		} catch (Exception ex) {
			throw new HttpApiException("Error parsing STRING response: "
					+ ex.getMessage());
		}
	}
	
	
}
